import { Button } from 'antd-mobile';

const LongTaskDemo = () => {
	const triggerLongTask = () => {
		const start = Date.now();

		// Blocking synchronous task
		while (Date.now() - start < 50) {
			// Empty loop to consume time
		}

		const duration = Date.now() - start;
		console.log(`同步任务完成，耗时 ${duration}ms`);
	};

	return (
		<div style={{ padding: 16 }}>
			<Button color='primary' size='middle' onClick={triggerLongTask}>
				长任务
			</Button>
		</div>
	);
};

export default LongTaskDemo;
